export default {
    setStorage(name,data){
        let dataType = typeof data;
        if(dataType === 'object'){
            window.localStorage.setItem(name,JSON.stringify(data));
        }
        else if(['number','string','boolean'].indexOf(dataType)>=0 ){
            window.localStorage.setItem(name,data);
        }
        else{
            console.log('This type is not suitable for local storage');
        }
    },
   getStorage(name){
       let data=window.localStorage.getItem(name);
       if(data){
           return JSON.parse(data);
       }
       else {
           return '';
       }
   },
   removeStorage(name) {
       return window.localStorage.removeItem(name);
   },
   clearStorage() {
       return window.localStorage.clear();
   }
}